import {
  stringify
} from 'qs';
import request from '../utils/request';
import {
  projrctListData
} from '../../mock/tabpanethree';
import {service_host} from './config';
const url = service_host;

export async function queryTestSheet() {
  return request(`${service_host}/api/testsheet`);
}

// 请求后台

export async function queryJiraData() {
  let res = request(`${service_host}/jira/bug/pandect`);
  return res;
}

export async function queryTestData() {
  return request(`${service_host}/test/pandect`);
}

//2
export async function querySingleProjectId(projectId) {
  let response = request(`${service_host}/singleproject/bug/pandect/${projectId}`);
  return response
}

export async function querySingleQualitySum(){

  let response = request(`${service_host}/singleproject/qualityfactor/pandect`);
  return response
}
//
export async function queryJiraDbEachMonthBug(year,projectId){
  let response = request(`${service_host}/singleproject/bug/${year}/${projectId}`,{
    method:'GET',
  });
  return response
}

export async function queryJiraDbAllMonthBug(year){
  let response = request(`${service_host}/jira/monthbug/${year}`,{
    method:'GET',
  });
  return response
}

export async function queryProject(params) {
  return request(`${service_host}/api/project/${params}`);
}

// 自动化工作台
export async function queryAutoTestData() {
  return request('/api/testtools/autotest');
}

export async function queryAutoTestRunData() {
  return request('/api/testtools/autotest/testrun');
}

export async function queryProjectNotice() {
  return request('/api/projectss/notice');
}

export async function queryActivities() {
  return request('/api/activities');
}

export async function selectProjectNotice() {
  return request('/api/project/new/newnotice');
}

export async function selectActivities() {
  return request('/api/newactivities');
}

export async  function getdynamiclogs(){
  return request(`${service_host}/workbanch/dynamiclogs`);
}


export async function queryRule(params) {
  return request(`/api/rule?${stringify(params)}`);
}

export async function queryFakeTaskList(params) {
  return request(`/api/faketasklist?${stringify(params)}`);
}

export async function removeRule(params) {
  return request('/api/rule', {
    method: 'POST',
    body: {
      ...params,
      method: 'delete',
    },
  });
}

export async function removeFakeTaskList(params) {
  return request('/api/faketasklist', {
    method: 'POST',
    body: {
      ...params,
      method: 'delete',
    },
  });
}

export async function addRule(params) {
  return request('/api/rule', {
    method: 'POST',
    body: {
      ...params,
      method: 'post',
    },
  });
}

export async function addFakeTaskList(params) {
  return request('/api/faketasklist', {
    method: 'POST',
    body: {
      ...params,
      method: 'post',
    },
  });
}

export async function fakeSubmitForm(params) {
  return request('/api/forms', {
    method: 'POST',
    body: params,
  });
}

export async function fakeChartData() {
  return request('/api/fake_chart_data');
}

// 自定义请求
export async function opjectNameData() {
  return request('/api/opject_testmodea_data'); //projrctListData
}

// 自定义请求usermock
export async function queryUserManage(params) {
 //  console.log('useradd',params)
  return request(`${service_host}/user/add`,{
    method:'POST',
    body :params,
    
  });
}

export async function DeleteUserKey(params) {
 // console.log('DeleteUserKey',params)
  return request(`${service_host}/user/delete`,{
    method:'DELETE',
    body: params,
  })
}

export async function UpdataUserinfo(params){
  return request(`${service_host}/user/update`,{
    method:'POST',
    body:params,
  })
}

export async function queryUserList(params) {
 // console.log('params2222',params)
  return request(`${service_host}/user/query`,{
    method: 'POST',
    body :params,

  });
}

export async function queryTags() {
  return request('/api/tags');
}

export async function queryBasicProfile() {
  return request('/api/profile/basic');
}

export async function queryAdvancedProfile() {
  return request('/api/profile/advanced');
}

export async function queryFakeList(params) {
  return request(`/api/fake_list?${stringify(params)}`);
}

export async function selectFakeList(params) {
  return request(`/api/fake_list?${stringify(params)}`);
}

export async function fakeAccountLogin(params) {
  return request(`${service_host}/user/login`, {
    method: 'POST',
    body: params,
    // header:{
    //   "Access-Control-Allow-Origin": "http://127.0.0.1:8000",
    //   "Access-Control-Allow-Methods": "GET,POST,DELETE,OPTIONS",
    //   "Access-Control-Allow-Credentials": true,
    //   widthCredentials:true
    // },
    // mode:'cors'
  });
}

export async function fakeRegister(params) {
  return request(`${service_host}/user/register`, {
    method: 'POST',
    body: params,
  });
}

export async function queryNotices() {
  return request('/api/notices');
}

export async function queryCurrentUser(){

  return request(`${service_host}/currentUser`)
}